package com.coffeeloversupportlibrary.coffeelover.mercury.my.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatButton;

import com.bumptech.glide.Glide;
import com.coffeeloversupportlibrary.R;
import com.coffeeloversupportlibrary.coffeelover.mercury.entity.ShopRecord;


import java.util.ArrayList;
import java.util.List;

/**
 * @author 盛守义
 * @createTime 2021/11/25 20:20
 * @projectName TurningCoffee
 * @className RecordAdapter.java
 * @description TODO
 */
public class RecordAdapter extends BaseAdapter {
    private Context context;
    private List<ShopRecord.DataDTO.ExchangeListDTO> list = new ArrayList<>();

    private ImageView iv_img;
    private TextView tv_name, tv_date;
    private AppCompatButton btn_del;

    public RecordAdapter(){}

    public RecordAdapter(Context context, List<ShopRecord.DataDTO.ExchangeListDTO> list){
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        LayoutInflater layoutInflater = LayoutInflater.from(context);
        View layout = layoutInflater.inflate(R.layout.my_list_record, null);

        iv_img = layout.findViewById(R.id.iv_bimglshop);
        tv_name = layout.findViewById(R.id.tv_bnamelshop);
        tv_date = layout.findViewById(R.id.tv_time);
        btn_del = layout.findViewById(R.id.btn_exchangelshop);

        Glide.with(context).load(list.get(i).getGoodsImg()).into(iv_img);
        tv_name.setText(list.get(i).getGoodsName());
        tv_date.setText(list.get(i).getUpdateTime());

        return layout;
    }
}
